package com.ooqiu.gaming.ui.person.collect;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.ooqiu.gaming.R;
import com.ooqiu.gaming.base.BaseFragment;
import com.ooqiu.gaming.base.BaseSupportActivity;
import com.ooqiu.gaming.common.Constants;
import com.ooqiu.gaming.db.Channel;
import com.ooqiu.gaming.ui.main.thread.common.ChannelPageAdapter;
import com.ooqiu.gaming.ui.main.thread.index.content.IndexContentAdapter;
import com.ooqiu.gaming.view.Topbar;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

@Route(path = CollectActivity.PATH, extras = Constants.ROUTER_EXTRA_NEED_LOGIN)
public class CollectActivity extends BaseSupportActivity {
    public static final String PATH = "/user/collect";
    @BindView(R.id.topbar)
    Topbar mTopbar;
    @BindView(R.id.tab_channel)
    TabLayout mTabChannel;
    @BindView(R.id.page_collect_content)
    ViewPager mPageCollectContent;
    List<Channel> mChannels = new ArrayList<>();


    ChannelPageAdapter mChannelPageAdapter;

    @Override
    public int initContentView() {
        return R.layout.activity_collect;
    }

    @Override
    public void initInjector() {
        ButterKnife.bind(this);
    }

    @Override
    public void initUiAndListener() {
        mTabChannel.setupWithViewPager(mPageCollectContent);

        mChannels.add(new Channel(null, "1", String.valueOf(IndexContentAdapter.ITEM_SINGLE_PIC_CONTENT), "文章", Channel.MODULE_ID_INDEX, false, ""));
        mChannels.add(new Channel(null, "3", String.valueOf(IndexContentAdapter.ITEM_VIDEO_CONTENT), "视频", Channel.MODULE_ID_INDEX, false, ""));

        ChannelPageAdapter channelPageAdapter = new ChannelPageAdapter(getSupportFragmentManager(), mChannels, false) {
            @Override
            public Fragment createFragment(Channel channel) {
                return (BaseFragment) getRouter()
                        .build(CollectFragment.PATH)
                        .withInt("type", Integer.parseInt(channel.getCat_id()))
                        .navigation();
            }
        };
        mPageCollectContent.setAdapter(channelPageAdapter);
    }

    @Override
    protected boolean isApplyStatusBarTranslucency() {
        return false;
    }

    @Override
    protected boolean isApplyStatusBarColor() {
        return true;
    }

    @Override
    protected int toolbarIdRes() {
        return R.id.topbar;
    }

    @Override
    protected int statusLayoutId() {
        return 0;
    }


}
